using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

using buildingLib.human;
namespace _dmis.human
{
    public partial class Qiandao : _dmis.UIToolBase
    {
        public Qiandao()
        {
            InitializeComponent();
        }

        private void Qiandao_Load(object sender, EventArgs e)
        {
            departmentsBindingSource.DataSource = Departments.GetDepartments();            
        }

        private void departmentsComboBox_SelectedValueChanged(object sender, EventArgs e)
        {
            if(this.departmentsComboBox.SelectedValue!=null)
            {
                DepartEmployees.InvalidateCache();
                this.departEmployeesBindingSource.DataSource = DepartEmployees.GetEmployees(this.departmentsComboBox.SelectedValue.ToString());
            }
        }

        private void btn_OK_Click(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < this.departEmployeesDataGridView.Rows.Count; i++)
                {
                    DataGridViewRow row = departEmployeesDataGridView.Rows[i];
                    if (row.Cells[1].Value == null)
                        continue;
                    if ((bool)row.Cells[1].Value)
                    {
                        buildingLib.human.QianDao qd = buildingLib.human.QianDao.NewRecord();
                        qd.Employeeid = (Guid)row.Cells[0].Value;

                        qd.Save();
                    }
                }
                this.DialogResult = DialogResult.OK;
            }
            catch (Exception ex)
            {
                string s =ex.Message;
                MessageBox.Show(s);
            }
        }
    }
}

